home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Fades ƒ / Circle bulge fade.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  2.7 KB  |  91 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Circle bulge fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define    startgap            1
  32. #define    gapratio            6
  33. #define    zeropointH            15
  34. #define CorrectTime 3
  35. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  36. #define theWindowWidth (boundsRect.right-boundsRect.left)
  37.  
  38. pascal short CircleBulgeFade(Rect boundsRect, Pattern *thePattern);
  39.  
  40. /* This copies ovals that always run from the left of the screen to the right,
  41.    but start really squashed and get geometrically taller.  */
  42.    
  43. pascal short CircleBulgeFade(Rect boundsRect, Pattern *thePattern)
  44. {
  45.     Rect        theRect;
  46.     RgnHandle    curregion, boundsRgn, sectrgn;
  47.     Point        zeropoint;
  48.     int            cy=theWindowHeight/2;
  49.     int            gap=startgap;
  50.     
  51.     theRect.left=boundsRect.left;
  52.     theRect.right=boundsRect.right;
  53.     theRect.top=boundsRect.top+cy-gap;
  54.     theRect.bottom=boundsRect.top+cy+gap;
  55.         
  56.     boundsRgn=NewRgn();
  57.     SetRectRgn(boundsRgn, boundsRect.left, boundsRect.top, boundsRect.right, boundsRect.bottom);
  58.     sectrgn=NewRgn();
  59.     curregion=NewRgn();
  60.     zeropoint.v=boundsRect.top;
  61.     zeropoint.h=boundsRect.left+zeropointH;
  62.     do
  63.     {
  64.         StartTiming();
  65.  
  66.         SetEmptyRgn(curregion);
  67.         OpenRgn();
  68.             FrameOval(&theRect);  /* this makes the region for copying */
  69.         CloseRgn(curregion);
  70.  
  71.         SectRgn(curregion, boundsRgn, sectrgn);
  72.         FillRgn(sectrgn, *thePattern);
  73.  
  74.         theRect.top-=gap;
  75.         theRect.bottom+=gap;     /* make the oval taller */
  76.         gap++;
  77.         gap+=gap/gapratio;       /* make the oval grow faster next time */
  78.         
  79.         TimeCorrection(CorrectTime);
  80.     }
  81.     while (!(PtInRgn(zeropoint, curregion)));    /* quit when we hit zeropoint */
  82.  
  83.     FillRect(&boundsRect, *thePattern);            /* fill the whole screen to end it */
  84.     
  85.     DisposeRgn(curregion);
  86.     DisposeRgn(boundsRgn);
  87.     DisposeRgn(sectrgn);
  88.     
  89.     return 0;
  90. }
  91.